08. Step 4 Make a Callback Method

Step 4 Make a Callback Method

Question:

Start Quiz:

INSTRUCTOR NOTE:

View the login.html page now with the added callback function.

At the 1:00 minute mark, Lorenzo adds a template variable called STATE.

In order to populate that variable when the template is rendered, you need to pass it to the render_template function:

# Create anti-forgery state token
@app.route('/login')
def showLogin():
    state = ''.join(random.choice(string.ascii_uppercase + string.digits)
                    for x in xrange(32))
    login_session['state'] = state
    # return "The current session state is %s" % login_session['state']
    return render_template('login.html', STATE=state)